/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_ora_setLength.c                                  */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/17 by geyh                                 */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "../../../../../src/module/oracle/config.h"
#include "../../../test_ora_comm.h"
#include <oracle/ora_core.h>
#include <oracle/comm/ora_comm.h>
#include <oracle/tns/ora_packet.h>
#include <oracle/ttc/sql/ora_LnxLibThin.h>
#include <frct_comm.h>
#include <apmtest_comm.h>

#include "t_ora_LnxLibThin.h"

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

extern int DBLMAX;

/**
 * 异常测试
 */
static void __case1(void)
{
    char *p_bin = (char *) "403c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d38223f3e0a3c687562733e3c6875623e3c636f64653e3032373534343c2f40636f64653e3c706f72743e3032373534342d30323c2f706f72743e3c636d645f6f626a6563745f747970653e313c2f636d645f6f626a6563745f747970653e3c0c2f6875623e3c2f687562733e000f435f435f414343545245434f56455207c60b041316114a077874031d0e3b11fe403c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d227574662d38223f3e0a0a3c726f6f743e0a20203c6f726465725f696e666f3e0a20204020203c736f5f7365726961";
    char arr_payload[65536] = {'\0'};
    CU_ASSERT_EQUAL(apmtest_hex_string_to_bin(p_bin, arr_payload, sizeof(arr_payload)), FR_SUCC);
    unsigned int ui_payload_len = strlen(p_bin) / 2;
    char *p_out = NULL;

    CU_ASSERT_EQUAL(ora_lnxnuc(arr_payload, ui_payload_len, DBLMAX, &p_out), FR_FAIL);

    ora_free((void **) &p_out);

    return;
}


int add_suite_ora_lnxnuc(void)
{
    CU_pSuite pSuite = NULL;


    if ((pSuite = CU_add_suite(MODULE_NAME" ora_lnxnuc()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
